package com.hoopchina.ui.main;

import com.hoopchina.news.R;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;

/**
 * LoadMoreListItem
 * 加载更多条目
 * 
 *@author Neusoft
 */
public class LoadMoreListItem {

	private Context	              mContext;
	private LayoutInflater	      mInflater;
	private RelativeLayout	      mLoadMoreButtonLayout;
	private Button	              mLoadMoreButton;
	private ProgressBar	          mProgressBar;
	private INewsListViewObserver mLoadMoreButtonObserver;

	/**
	 * 构造器
	 */
	public LoadMoreListItem(Context context) {
		init(context);
	}
    /**
     * 类初始化数据
     * @param context
     */
	void init(Context context) {
		mContext = context;
		
		mInflater = LayoutInflater.from( mContext );

	    mLoadMoreButtonLayout =(RelativeLayout)mInflater.inflate( R.layout.loadmorebutton, null );
	    mLoadMoreButton = (Button)mLoadMoreButtonLayout.findViewById(R.id.buttonLoadMore);
	    mProgressBar = (ProgressBar)mLoadMoreButtonLayout.findViewById(R.id.progressBarLoadMore);
	    mLoadMoreButton.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				mLoadMoreButtonObserver.onClickLoadMoreButton();					
			}
		});
	}
	
	public RelativeLayout getLayout() {
		return mLoadMoreButtonLayout;
	}

	public void setProgressBarVisibility(int v) {
		mProgressBar.setVisibility(v);
	}
	public void setLoadMoreButtonObserver(INewsListViewObserver observer) {
		mLoadMoreButtonObserver = observer;
	}
	public void setVisibility(int v) {
		mLoadMoreButtonLayout.setVisibility(v);
	}

}
